import html2Canvas from 'html2canvas'
let MicroMessenger=navigator.userAgent.match(/MicroMessenger/i)
export async function downImg(name,domid,show) {
    let nodeid = document.querySelector('#'+domid)
    let pageData=''
    window.scrollTo(0, 1);
    console.log(nodeid);
    await html2Canvas(nodeid, {
        allowTaint: true,
        useCROS: true,
        height: nodeid.offsetHeight || nodeid.scrollHeight || nodeid.clientHeight,
        width: nodeid.offsetWidth || nodeid.scrollWidth || nodeid.clientWidth,
        x:0,
        y:0,
        }).then(function (canvas) {
            canvas.style.width = "100%";
            canvas.style.height= "auto";
            pageData = canvas.toDataURL('image/jpeg', 1.0)
            // if(!MicroMessenger){
            // }
            // const link = document.createElement('a') 
            // link.style.display = 'none'
            // link.href=pageData
            // link.download = name+'.jpg'
            // document.body.appendChild(link)
            // link.click()
            // document.body.removeChild(link)
        })
        return pageData 
    // if(MicroMessenger){
    // }
}